Declare Function AppGetCurrentApp Lib "DBAPI10.dll" () As Long
Declare Function AppSetupFilter Lib "DBAPI10.dll" (ByVal hApp As Long, ByVal ReadWrite As Boolean, ByVal ext As String, ByVal descr As String) As Boolean
Sub Main()
End Sub
'this function removes duplicates of IDS
Public Function CorrectIDs(ByVal Dr As Drawing)
On Error GoTo E
Dim curSpaceMode As ImsiSpaceModeType
Dim Pss As PaperSpaces
Dim Ps As PaperSpace
curSpaceMode = Dr.Properties("TileMode")
'correct IDs for graphics in blocks table
Call correctBlockTableIDs(Dr.Blocks)
Set Pss = Dr.PaperSpaces
' correct IDs for graphics in PaperSpaces
For Each Ps In Pss
Call correctIDGraphic(Ps.Graphics)
Next
' correct IDs for graphics in Model spaces
Set Ps = Nothing
Set Pss = Nothing
If curSpaceMode = imsiModelSpace Then
Call correctIDGraphic(Dr.Graphics)
Else
Dr.Properties("TileMode") = imsiModelSpace
Call correctIDGraphic(Dr.Graphics)
Dr.Properties("TileMode") = curSpaceMode
End If
Exit Function
E:
MsgBox LoadResString(116), vbOKOnly, "CorectIDS function failed! " & Err.Description
End Function
Private Function correctIDGraphic(Grs As Graphics)
Dim g As Graphic
Dim g1 As Graphic
Dim gtmp As Graphic
Dim grsParent As Graphics
Dim id As Long
Dim id1 As Long
Dim Index As Long
For Each g In Grs
id = g.id
g.Deleted = True
On Error Resume Next
Set g1 = Grs.GraphicFromID(id)
Err.Clear
If Not g1 Is Nothing Then ' And (g <> g1) Then 'Or g.Index <> g1.Index Then
g.Deleted = False
Set grsParent = g.Parent
Index = g.Index
Set g = grsParent.Remove(Index)
g.id = 0
If Index = 0 Then
grsParent.AddGraphic g, 0
ElseIf (Index = grsParent.Count) Then
grsParent.AddGraphic g
Else
grsParent.AddGraphic g, Index
End If
' If Index <> g.Index Then
' MsgBox "ID is not changed"
' End If
End If
g.Deleted = False
If (g.TypeByValue = imsiGroup) Then
Call correctIDGraphic(g.Graphics)
End If
Set g1 = Nothing
Set g = Nothing
Next
End Function
Private Function correctBlockTableIDs(Bks As Blocks)